<{if $showColloc}>
<h4>搭配商品</h4>
  <input type="hidden" name="hasColloc" value=1 />
  <table width="100%" border="0" cellspacing="0" cellpadding="2" class="gridlist">
  <col class="Colsn"></col>
  <col></col>
  <col class="Colamount"></col>
  <col class="Colamount"></col>
  <col class="Colamount"></col>
  <col class="Coloption-1b"></col>
    <thead>
      <tr>
        <th><{t}>货号<{/t}></th>
        <th><{t}>商品名称<{/t}></th>
        <th><{t}>价格<{/t}></th>
        <th><{t}>购买数量<{/t}></th>
        <th><{t}>小计<{/t}></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
	<!-- alone add start 主商品块 -->
	<{foreach from=$coGoods item=colloc key=k}>
		<{assign var="itemid" value=$colloc.goods.item_id}>
		<{assign var="itemprice" value=$colloc.goods.price}>
		<{assign var="itemnums" value=$colloc.goods.nums}>
		<{assign var="iLoop" value=$colloc.goods.loopKey}>
		<tr>
		  <input type="hidden" name='aCoItems[<{$itemid}>]' value='<{$colloc.goods.product_id}>'>
		  <td><{$colloc.goods.bn}></td>
		  <td><{$colloc.goods.name}></td>
		  <td><{input type="unsigned" required="true" coKey="{$iLoop}" class="itemPrice_{$iLoop} itemco" name="aCoPrice[{$itemid}]" value=$itemprice size=8 }></td>
		  <td><{input type="positive" required="true" coKey="{$iLoop}" class="itemNum_{$iLoop} itemco" name="aCoNum[{$itemid}]" value=$itemnums size=4 }></td>
		  <td class="itemSub_<{$iLoop}> itemCount Colamount"><{$colloc.goods.amount}></td>
		  <td><span class="sysiconBtnNoIcon" onClick="delgoods(this)"><{t}>删除<{/t}></span></td>
		</tr>
		<!-- alone add end 主商品块 -->
		<!-- alone add start 搭配商品 -->
		<{foreach from=$colloc.items item=aItems key=iLoop}>
		<{assign var="itemid" value=$aItems.item_id}>
		<{assign var="itemprice" value=$aItems.price}>
		<{assign var="itemnums" value=$aItems.nums}>
		<tr>
		  <input type="hidden" name='aCoItems[<{$aItems.item_id}>]' value='<{$aItems.product_id}>'>
		  <td><{$aItems.bn}></td>
		  <td><{$aItems.name}></td>
		  <td><{input type="unsigned" required="true" coKey="{$iLoop}" class="itemPrice_{$iLoop} itemco" name="aCoPrice[{$itemid}]" value=$itemprice size=8 }></td>
		  <td><{input type="positive" required="true" coKey="{$iLoop}" class="itemNum_{$iLoop} itemco" name="aCoNum[{$itemid}]" value=$itemnums size=4 }></td>
		  <td class="itemSub_<{$iLoop}> itemCount Colamount"><{$aItems.amount}></td>
		  <td><span class="sysiconBtnNoIcon" onClick="delgoods(this)"><{t}>删除<{/t}></span></td>
		</tr>
		<!-- alone add end 搭配商品 -->
		<{/foreach}>
	<{/foreach}>
    </tbody>
  </table>
<h4>基本商品</h4>
 
<script>
 var itemAmount=0;
 $ES(".itemco","moneyItems").each(function(item, index, itobj){
 item.addEvent('change',function(e){
  e=new Event(e);
  var ipt=e.target;
  if(ipt.className.split('_').length > 1){
   var key=ipt.get('coKey');
   var result=$E('.itemPrice_'+key,'moneyItems').getValue().toFloat()*$E('.itemNum_'+key,'moneyItems').getValue().toInt();
   $E('.itemSub_'+key).setText(result);
  }
  countF();
  });
 });
 
 function countF(){
  $('iditem_amount').value=function(){
    var count=0;
    $ES(".itemCount","moneyItems").each(function(item){
     count += item.getText().toFloat()*1;
    });
    return count;
   }();
  $('idtotal_amount').value=function(){
  	var cost_protect = 0;
	if($('idis_protect').checked){
		cost_protect = $('idcost_protect').value.toFloat();
	}
	var cost_tax = 0;
	if($('idis_tax').checked){
		cost_tax = Number($('idcost_tax').value);
	}
    var count=0;
    count = Number($('iditem_amount').value) + cost_protect + $('idcost_freight').value.toFloat() + Number($('idcost_payment').value) + cost_tax + Number($('iddiscount').value) - Number($('idpmt_amount').value);
    return count.round(2);
   }();
 }
 
 $('idis_protect').addEvent('click',function(e){
  $('idcost_protect').disabled = !$('idis_protect').checked;
  countF();
 });
 
 $('idis_tax').addEvent('click',function(e){
  $('idcost_tax').disabled = !$('idis_tax').checked;
  countF();
//  if($('idis_tax').checked){
//   $('idtax_company').style.display = 'block';
//  }else{
//   $('idtax_company').style.display = 'none';
//  }
 });
 </script>
<{/if}>